package com.share.example.spider.utils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;

public class HtmlUtil {

    public static Document getDocument(String url) {
        Document doc = null;
        try {
            doc = Jsoup.connect(url)
                    .userAgent("Mozilla")
                    .cookie("auth", "token")
                    .timeout(3000)
                    .get();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return doc;
    }

    public static String getStr(String url) {
        String res = null;
        Document document = getDocument(url);
        if (document != null) {
            res = document.toString();
        }
        return res;
    }
}
